package com.da.javatest.leetCode2;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Code830 {
    public static void main(String[] args) {
        System.out.println(new Code830().largeGroupPositions("aaa"));
    }

    public List<List<Integer>> largeGroupPositions(String S) {
        S += "-";
        List<List<Integer>> result = new ArrayList<>();
        int index = 0, start = 0;
        char preChar = ' ';
        for (char c : S.toCharArray()) {
            if (preChar != c) {
                if (index - start > 2) {
                    result.add(Arrays.asList(start, index - 1));
                }
                start = index;
            }
            preChar = c;
            index++;
        }
        return result;
    }
}
